//
//  ViewController.m
//  whfdemo002
//
//  Created by 王洪飞 on 2024/6/12.
//


#import "ViewController.h"
#import "Render.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

@interface ViewController ()
@property (nonatomic, strong) EAGLContext *mContext;
@property (nonatomic, strong) Render *render;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.mContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
    [EAGLContext setCurrentContext:self.mContext];
    
    GLKView *view = (GLKView *)self.view;
    view.context = self.mContext;
    
    
    view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
    view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
    
    self.render = [[Render alloc] init];
    
}

-(void)glkView:(GLKView *)view drawInRect:(CGRect)rect{
//    NSLog(@"draw %d : %d", view.drawableWidth, view.drawableHeight);
//    glViewport(0, 0, view.drawableWidth, view.drawableHeight);
    glClearColor(0.0, 0.5, 1, 1);
    glClear(GL_COLOR_BUFFER_BIT);
    [self.render draw];
    
    
}

@end
